home *** CD-ROM | disk | FTP | other *** search
/ LOGIC Apps / Logic-APPLE_II_APPS.iso / mac / LOGIC Apple II 5.25" Library - ProDOS / PRO027A.dsk / ADB.READER.bas next >
BASIC Source File  |  2012-02-16  |  6KB  |  112 lines

  1. 100  REM *** Open-Apple's ADB Reader ***
  2. 101  REM    by Tom Weishaar, Feb 1987
  3. 1000  REM program initialization
  4. 1010  LOMEM: 16384 + PEEK(105) + PEEK(106) *256: REM create 16384-byte buffer
  5. 1020  CLEAR : REM restart point for reading another file
  6. 1030  DEF  FN PK2(ADR) =  PEEK(ADR) + PEEK(ADR +1) *256: REM 2-bye peek function
  7. 1032  DIM CN$(30): REM this array is for category names
  8. 1034  DIM C$(30): REM this array is for the information in categories
  9. 1036  DIM TB(30,2): REM this array is for category TAB positions on screen
  10. 1038  DIM MO$(12): REM this array is for the names of the months
  11. 1040 MO$(1) = "Jan":MO$(2) = "Feb":MO$(3) = "Mar"
  12. 1042 MO$(4) = "Apr":MO$(5) = "May":MO$(6) = "Jun"
  13. 1044 MO$(7) = "Jul":MO$(8) = "Aug":MO$(9) = "Sep"
  14. 1046 MO$(10) = "Oct":MO$(11) = "Nov":MO$(12) = "Dec"
  15. 1050 BBG =  FN PK2(105) -16384: REM bbg points to the beginning of our buffer
  16. 1052 BEN = BBG +16384/2: REM ben points to the end of our buffer
  17. 1054 PNTR = BBG: REM pntr points to our position in the buffer
  18. 1056 BYTE = 0: REM byte points to our position in the file
  19. 1060  PRINT  CHR$(4);"PR#3": PRINT : REM 80-column screen required
  20. 1062  VTAB 10
  21. 1064  PRINT "What is the name of the AppleWorks database file you want to see?"
  22. 1066  PRINT 
  23. 1068  INPUT F$: HOME 
  24. 1070  IF F$ = ""  THEN  END 
  25. 1100  REM load first section of file and dig stuff out of the header
  26. 1110  GOSUB 5500: REM load file
  27. 1120 HL =  FN PK2(PNTR) +2: IF HL >1017  THEN 5900: REM header length
  28. 1122 NR =  FN PK2(PNTR +36): REM # of records in file
  29. 1124 NC =  PEEK(PNTR +35): IF NC >30  THEN 5900: REM # of categories
  30. 1126 NF =  PEEK(PNTR +38): IF NF >8  THEN 5900: REM # of report formats
  31. 1130  FOR N = 0 TO NC -1: REM get screen positions
  32. 1132 TB(N,0) =  PEEK(PNTR +186 +N): REM screen sequence left-top to right-bot
  33. 1134 TB(N,1) =  PEEK(PNTR +114 +N): REM horizontal screen position
  34. 1136 TB(N,2) =  PEEK(PNTR +150 +N): REM vertical screen position
  35. 1138  NEXT 
  36. 1140 PNTR = PNTR +357: REM get category names
  37. 1142  FOR N = 0 TO NC -1
  38. 1144 C$ = "": FOR I = 1 TO  PEEK(PNTR):C$ = C$ + CHR$( PEEK(PNTR +I)): NEXT 
  39. 1146 CN$(N) = C$:PNTR = PNTR +22
  40. 1148  NEXT 
  41. 1150 PNTR = PNTR +NF *600: REM skip over 600-byte-each report formats
  42. 1152  IF PNTR =  >BEN  THEN  GOSUB 5500: REM do formats extend beyond buffer?
  43. 1160  REM just for fun, draw an AppleWorks-like screen for display
  44. 1162  PRINT "File: "; RIGHT$(F$,20): PRINT : PRINT "Selection: All records"
  45. 1164  VTAB 1: POKE 1403,28: PRINT "Open-Apple's ADB.READER"
  46. 1166  VTAB 7: FOR I = 1 TO 8: PRINT "==========";: NEXT 
  47. 1168  VTAB 23: FOR I = 1 TO 8: PRINT "----------";: NEXT 
  48. 1170  PRINT "Press spacebar to see next record.";
  49. 1200  REM get records and display them on the screen
  50. 1210  FOR R = 0 TO NR
  51. 1220  GOSUB 5000: REM this loads c$(n) with record's data
  52. 1230  REM the rest of this just displays the data on the screen
  53. 1232  VTAB 6: POKE 1403,0
  54. 1234  IF R = 0  THEN  PRINT "Standard Values for this file:": GOTO 1238
  55. 1236  PRINT "Record ";R;" of ";NR;":"; CHR$(29): REM chr$(29) clears line
  56. 1238  FOR N = 0 TO NC -1
  57. 1240  VTAB TB(N,2) +1: POKE 1403,TB(N,1) -1
  58. 1242  PRINT CN$(TB(N,0) -1);": ";C$(TB(N,0) -1); CHR$(29)
  59. 1250  NEXT 
  60. 1260  VTAB 24: POKE 1403,37: GET A$: PRINT A$;: REM wait for key
  61. 1270  NEXT 
  62. 1300  REM end game
  63. 1310  HOME : VTAB 12
  64. 1320  PRINT "That's all the records in ";F$
  65. 1330  PRINT 
  66. 1340  PRINT "Would you like to see another? <Y/N> ";: GET A$: PRINT A$: HOME 
  67. 1350  IF A$ = "Y"  OR A$ = "y"  THEN 1020
  68. 1360  END 
  69. 5000  REM read record's categories into c$(1)...c$(n)
  70. 5010 RL =  FN PK2(PNTR):PNTR = PNTR +2: REM rl is record's length
  71. 5020  IF PNTR +RL =  >BEN  THEN  GOSUB 5500: REM does record extend beyond buffer?
  72. 5030 NB = 0: REM init # of blanks to 0
  73. 5040  FOR N = 0 TO NC -1: GOSUB 5100: NEXT : REM get category data
  74. 5050  GOSUB 5100: IF CBYTE < >255  THEN 5900: REM get $ff at end of record
  75. 5060  RETURN 
  76. 5100  REM read a single category's data into c$(n)
  77. 5110  IF NB >0  THEN 5184: REM in the middle of multiple blanks?
  78. 5112 CBYTE =  PEEK(PNTR):PNTR = PNTR +1: REM get control byte
  79. 5114  IF CBYTE >127  THEN 5180: REM start multiple blank categories
  80. 5116 T =  PEEK(PNTR): IF T <128  THEN 5160: REM dte or time category?
  81. 5118  IF T = 212  THEN 5130
  82. 5120  REM category contains a date
  83. 5122 YR$ =  CHR$( PEEK(PNTR +1)) + CHR$( PEEK(PNTR +2))
  84. 5124 MO$ = MO$( PEEK(PNTR +3) -64)
  85. 5126 DY$ =  CHR$( PEEK(PNTR +4)) + CHR$( PEEK(PNTR +5))
  86. 5128 C$ = MO$ +" " +DY$ +" " +YR$: GOTO 5190
  87. 5130  REM category contains a time
  88. 5132 M$ = "AM":HR = ( PEEK(PNTR +1) -65)
  89. 5134  IF HR >11  THEN M$ = "PM": IF HR >12  THEN HR = HR -12
  90. 5136 HR$ =  STR$(HR): IF HR <10  THEN HR$ = "0" +HR$
  91. 5138 MI$ =  CHR$( PEEK(PNTR +2)) + CHR$( PEEK(PNTR +3))
  92. 5140 C$ = HR$ +":" +MI$ +" " +M$: GOTO 5190
  93. 5160  REM category contains ASCII-string data
  94. 5162 C$ = "": FOR I = PNTR TO PNTR +CBYTE -1:C$ = C$ + CHR$( PEEK(I)): NEXT 
  95. 5164  GOTO 5190
  96. 5180  REM category is blank
  97. 5182 NB = CBYTE -128: REM cbyte-$80 is # of blank categories
  98. 5184 C$(N) = "":NB = NB -1: GOTO 5195
  99. 5190 C$(N) = C$:PNTR = PNTR +CBYTE: REM advance pointer to next category
  100. 5195  RETURN 
  101. 5500  REM load section of file into buffer
  102. 5510 BYTE = BYTE +(PNTR -BBG):PNTR = BBG
  103. 5520  PRINT  CHR$(4);"BLOAD";F$;",TADB,L8192,A";BBG;",B";BYTE
  104. 5530  RETURN 
  105. 5900  REM the file doesn't look right--probably a program, not a file, bug
  106. 5910  HOME : VTAB 10
  107. 5920  PRINT "I've encountered an error in the file's structure"
  108. 5930  PRINT "   in record ";R;" and category ";N;"."
  109. 5940  PRINT 
  110. 5950  PRINT "The file buffer begins at ";BBG;" and ends at ";BEN;"."
  111. 5960  PRINT "   The buffer pointer is at byte ";PNTR;"."
  112. 5990  END